#ifndef MESSAGEPARSER_H
#define MESSAGEPARSER_H

#include <QObject>

class MessageParser : public QObject {
    Q_OBJECT

public:
    explicit MessageParser(QObject *parent = nullptr);
    ~MessageParser();

    enum State {
        WAIT_START,
        IN_MESSAGE
    };

    static const char START_MSG = '$';
    static const char END_MSG = ';';

    void unpack(const char *data);

signals:
    void newData(QStringList data);

private:
    State mState;
    QString mReceivedData; // 用于累积接收到的消息内容
};

#endif // MESSAGEPARSER_H
